/*
 * Copyright (c) 2011-2012 Alexander Dubu
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * o  Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * o  Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * o  Neither the name Axil nor the names of its contributors may be used to
 *    endorse or promote products derived from this software without specific
 *    prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package axil.api.error;

import axil.api.Argument;
import axil.api.Formatted;


/**
 * The base exception from which all user-facing exceptions originating from
 * the Axil runtime descend. Axil will throw two types of exceptions: internal
 * exceptions and localized exceptions.
 * <ul>
 * 		<li>Internal exceptions are runtime exceptions that indicate a problem
 * 			in configuration or use of the Axil runtime. These exceptions are
 * 			not localized and not suitable for display to the user.</li>
 * 		<li>Localized exceptions are designed to have the message contained
 * 			within them presented to the user. Any exception descending from
 * 			AxilException contains fully localized information.</li>
 * </ul>
 * A localized message can be obtained by calling the getMessage() or toString()
 * methods on this class. The actual message is assembled and localized
 * automatically using the installed translation adapters. If the host
 * application needs an alternate mechanism, then the key and values used to
 * assemble the message are also provided.
 */
public abstract class AxilException extends RuntimeException
	implements Formatted {
	protected AxilException()					{ }
	protected AxilException(Throwable cause)	{
		super(cause);
	}


	/**
	 * Get the translation key. The translation key is the key used to look up
	 * the actual translation text. This key may contain '-' characters but
	 * will not contain any whitespace or other punctuation.
	 *
	 * @return
	 * 	Returns the translation key, which is never null or empty.
	 */
	public abstract String key();


	/**
	 * Get the optional message values. Values are name/value pairs containing a
	 * key and the raw, unformatted value.
	 *
	 * @return
	 * 	Returns the message values. The array is never null, but may be empty.
	 */
	public abstract Argument[] values();
}
